package cn.fbs.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.io.File;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Value("${resource.locations}")
    private String resourceLocations;
    /**
     * 作用和修改tomcat的server.xml中的docBase一样 映射本地静态资源路径和swagger路径
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**").addResourceLocations("file:"+resourceLocations+ File.separator)
       .addResourceLocations("classpath:/static/").addResourceLocations("classpath:/META-INF/resources/");
    }

//    @Autowired
//    private AuthorityInterceptor authorityInterceptor;
//
//
//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(authorityInterceptor)
//                .addPathPatterns("/**")
//                .excludePathPatterns("/user/**")
//                .excludePathPatterns("/users/**")
//                .excludePathPatterns("/users/regist")
//                .excludePathPatterns("/upload/**")
//                .excludePathPatterns("/imageData/uploadImageFile")
//                .excludePathPatterns("/undefined/imageData/uploadImageFile")
//                .excludePathPatterns("/imageData/uploadVideoFile")
//                .excludePathPatterns("/undefined/imageData/uploadVideoFile")
//                .excludePathPatterns("/imageData/uploadDataFile")
//                .excludePathPatterns("/undefined/imageData/uploadDataFile")
//                .excludePathPatterns("/imageData/batchUpload")
//                .excludePathPatterns("/photoAlbum/uploadPhotoAlbumFile")
//                .excludePathPatterns("/file/fileDown")
//                .excludePathPatterns("/js/**")
//                .excludePathPatterns("/css/**")
////                .excludePathPatterns("/img/**")
//                .excludePathPatterns("/index.html")
//                .excludePathPatterns("/trial/**")
//                .excludePathPatterns("/collectionUnit/**")
//                .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**");
//        ;
//    }
}
